//
//  CHStarView.m
//  CarFile
//
//  Created by 陈浩 on 2017/4/10.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHStarView.h"

@implementation CHStarView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        
        for (int i = 0; i < 5; i++) {
            
            UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(i *(5 +15*ScaleX), 0, 15*ScaleX, 15*ScaleY)];
            imgView.image = [UIImage imageNamed:@"star"];
            [self addSubview:imgView];
            
        }
        
        
    }
    return self;
    
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        
        
        for (int i = 0; i < 5; i++) {
            
            UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(i *(5 +15*ScaleX), 0, 15*ScaleX, 15*ScaleY)];
            imgView.image = [UIImage imageNamed:@"star"];
            [self addSubview:imgView];
            
        }
        
    }
    return self;
    
}


-(void)setStarNum:(NSInteger)starNum{
    _starNum = starNum;
    
    for (NSInteger i = 0; i < starNum; i++) {
        
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(i *(5 +15*ScaleX), 0, 15*ScaleX, 15*ScaleY)];
        imgView.image = [UIImage imageNamed:@"star_highlighted"];
        [self addSubview:imgView];
        
        [self setNeedsLayout];
        
    }
    
    
    
    
    
}

@end
